import { Component } from '@angular/core';
import { Student } from './model/student';
import { StudentService } from './service/student.service';
import { StudentVo } from './vo/studentvo';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = '大学';
//变量类型声明
  textvalue:string;
  numbervalue:number;

  student:Student;
  studentvo:StudentVo;


  constructor(private studentservice:StudentService)
  {}









//初始化方法
ngOnInit() {
//变量的初始化
this.textvalue='今天天气很好';
this.numbervalue=58+76;
this.studentvo=new StudentVo();

this.student=new Student();
// this.student.name="测试姓名"
// this.student.sex="男";
// this.student.birthday=new Date().getTime();

this.studentservice.getAnObject()
.then((data:any)=>{
  this.student=data;
})



}


//添加事件

add(){

console.dir(this.studentvo);

this.studentservice.addStudentInfo(this.studentvo)
.then((data:any)=>{
//请求事件完成后
this.studentservice.getAnObject()
.then((data:any)=>{
  this.student=data;
})


})


}






}